package mvc.command.character
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.adobe.cairngorm.control.CairngormEventDispatcher;
	
	import iris.managers.IrisPopUpManager;
	
	import mvc.control.CharacterEvent;
	
	import mx.core.Application;
	import mx.core.IFlexDisplayObject;
	
	import nz.co.codec.flexorm.EntityManager;
	
	import orm.fantasy.TblCharacterVO;
	
	import view.design.DesignCharacters;

	public class AddCharacterFinishCmd extends CharacterCmd implements ICommand
	{
		public function execute(event:CairngormEvent):void
		{
			var vo:TblCharacterVO = (event as CharacterEvent).tblCharacterVO;
			// 追加到数据库
			EntityManager.instance.save(vo);
			// 追加到画面
			var mvcEvent:CharacterEvent = new CharacterEvent(CharacterEvent.NEW_DESIGN_CHARACTER, vo);
			CairngormEventDispatcher.getInstance().dispatchEvent(mvcEvent);
			// 删除弹出
			IrisPopUpManager.removePopUp(event.data.popUp as IFlexDisplayObject, IrisPopUpManager.EFFECT_BLUR);
		}
	}
}